package main

import (
	"net/http"
	"xuper-reins-go/based"
	"xuper-reins-go/server"
)

func main() {
	//todo 进入fabric目录 make restart
	//01启动区块链节点，02在sdk中创建通信客户端
	//server.Run()
	//based.Setup() //整个系统只运行一次

	//hospital := &server.Peer{Typ: 1, Hospital: Hospital1, Port: "8880"}
	//store1 := &server.Peer{Typ: 2, Store: Store1, Port: "8881"}
	//store2 := &server.Peer{Typ: 2, Store: Store2, Port: "8882"}
	//store3 := &server.Peer{Typ: 2, Store: Store3, Port: "8883"}
	//controller := &server.Peer{Typ: 3, Controller: Controller, Port: "8884"}

	//设置处理静态资源，如css和js文件
	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("views/static/"))))
	http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("views/css/"))))
	http.Handle("/fonts/", http.StripPrefix("/fonts/", http.FileServer(http.Dir("views/fonts/"))))
	http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.Dir("views/images/"))))
	http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir("views/js/"))))
	//直接去html页面
	http.Handle("/pages/", http.StripPrefix("/pages/", http.FileServer(http.Dir("views/pages"))))
	//去登录
	http.HandleFunc("/login", based.Login)
	//去上传CR
	http.HandleFunc("/upload", server.GetContCR)
	//去上传CP
	http.HandleFunc("/upload1", based.GetContCP)
	//去首页
	http.HandleFunc("/index", based.Gotohome)
	//去发布
	//http.HandleFunc("/post", based.Postinfo)
	//去获取
	http.HandleFunc("/get", based.GetInfo)
	//区块链浏览器
	http.HandleFunc("/block", based.GetBlockInfo)
	http.ListenAndServe(":8080", nil)

}
